package edu.ynu.se.xiecheng.achitectureclass.project.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import edu.ynu.se.xiecheng.achitectureclass.project.entity.Device;
import lombok.Data;
import javax.persistence.*;
import javax.validation.constraints.Size;
import java.util.Date;
import java.util.List;

import lombok.NoArgsConstructor;
import org.jetbrains.annotations.NotNull;
@Data
@Entity
@NoArgsConstructor
@Table(name = "GreenHouse")
public class Greenhouse {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @NotNull
    @Size(max = 100)
    private String name;

    @Size(max = 200)
    private String address;

    private Double area;

    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "create_time")
    private Date createTime;

    @OneToMany(mappedBy = "greenhouse", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
    @JsonIgnore
    private List<Device> devices;
}